package Day02;

public class Test02 {
    public static void main(String[] args) {
        String name = "Hanserwei";
        reverString(name);

        String name2 = "Hanserwei12312345645AGHSHJGHJSGHJS";
        countUpperLoerAndDigit(name2);

    }

    private static void countUpperLoerAndDigit(String name2) {
        // 判断有多少大小写数字字符
        int countUpperCase = 0;
        int countLowerCase = 0;
        int countDigit = 0;
        for (int i = 0; i < name2.length(); i++) {
            char c = name2.charAt(i);
            if (Character.isUpperCase(c)) {
                countUpperCase++;
            } else if (Character.isLowerCase(c)) {
                countLowerCase++;
            } else if (Character.isDigit(c)) {
                countDigit++;
            }
        }
        System.out.println("大写字母有" + countUpperCase + "个");
        System.out.println("小写字母有" + countLowerCase + "个");
        System.out.println("数字有" + countDigit + "个");
    }

    private static void reverString(String name) {
        char[] nameCharArray = name.toCharArray();
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = nameCharArray.length - 1; i >= 0; i--) {
            stringBuilder.append(nameCharArray[i]);
        }
        System.out.println(stringBuilder);
    }
}
